//package com.per.mybootall.config;
//
//import com.sun.istack.NotNull;
//import org.quartz.Scheduler;
//import org.quartz.ee.servlet.QuartzInitializerListener;
//import org.springframework.beans.factory.config.PropertiesFactoryBean;
//import org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.io.ClassPathResource;
//import org.springframework.scheduling.quartz.SchedulerFactoryBean;
//
//import java.io.IOException;
//import java.util.Properties;
//
///**
// * Created with IntelliJ IDEA.
// *
// * @author: yyy
// * Date: 2022/6/7
// * Time: 9:49
// * Description:
// */
//@Configuration
//public class QuartzConfig implements SchedulerFactoryBeanCustomizer {
//
//  @Bean
//  public Properties properties() throws IOException {
//    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
//    // 对quartz.properties文件进行读取
//    propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
//    // 在quartz.properties中的属性被读取并注入后再初始化对象
//    propertiesFactoryBean.afterPropertiesSet();
//    return propertiesFactoryBean.getObject();
//  }
//
//  @Bean
//  public SchedulerFactoryBean schedulerFactoryBean() throws IOException {
//    SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
//    schedulerFactoryBean.setQuartzProperties(properties());
//    return schedulerFactoryBean;
//  }
//
//  /*
//   * quartz初始化监听器
//   */
//  @Bean
//  public QuartzInitializerListener executorListener() {
//    return new QuartzInitializerListener();
//  }
//
//  /*
//   * 通过SchedulerFactoryBean获取Scheduler的实例
//   */
//  @Bean
//  public Scheduler scheduler() throws IOException {
//    return schedulerFactoryBean().getScheduler();
//  }
//
//  /**
//   * 使用阿里的druid作为数据库连接池
//   */
//  @Override
//  public void customize(@NotNull SchedulerFactoryBean schedulerFactoryBean) {
//    schedulerFactoryBean.setStartupDelay(2);
//    schedulerFactoryBean.setAutoStartup(true);
//    schedulerFactoryBean.setOverwriteExistingJobs(true);
//  }
//}
